import { Injectable } from '@nestjs/common';
import * as dayjs from 'dayjs';

@Injectable()
export class TimeScheduleService {
    runTaskAtTime(time: dayjs.Dayjs, func: Function) {
        let now = dayjs();
        if (time <= now) {
            return setTimeout(func, 0);
        }
        setTimeout(func, time.valueOf() - now.valueOf());
    }
}
